<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/icons-extra.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">	
			<a class="mui-icon mui-icon-back mui-action-back mui-pull-left"></a>
			<h1 class="mui-title ">Device</h1>
			<a class="mui-icon-extra mui-icon-extra-topic mui-pull-right" style="margin-top: 10px;"
				 onclick="openWindow('docDevice','../doc/device.html?v=20190621')"></a>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded">
				<div class="mui-row">
					Device模块管理设备信息，用于获取手机设备的相关信息，如IMEI、IMSI、型号、厂商等。通过plus.device获取设备信息管理对象。
				</div>
				<div class="mui-button-row">
					<button type="button" class="mui-btn mui-btn-success mui-btn-block" onclick="getDeviceInfo()">获取设备信息</button>
					<button type="button" class="mui-btn mui-btn-primary mui-btn-block" onclick="getSysInfo();">获取系统信息</button>
					<button type="button" class="mui-btn mui-btn-danger mui-btn-block" onclick="deviceBeep();">蜂鸣</button>
					<button type="button" class="mui-btn mui-btn-warning mui-btn-block" onclick="deviceVibrate();">震动</button>
					<button type="button" class="mui-btn mui-btn-purple mui-btn-block"  onclick="dial()">直接拨打电话</button>
				</div>
				<div class="mui-row" id="divInfo"></div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/app.js" ></script>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function(){
				plus.device.setWakelock(true);//设置应用是否保持唤醒（屏幕常亮）状态
			});
			mui.back = function(){
				plus.device.setWakelock(false);
				plus.webview.currentWebview().close();
			}
			function outSet(message){
				document.getElementById("divInfo").innerText = message;
			}
			
			function outLine(message){
				var text = document.getElementById("divInfo").innerText;
				document.getElementById("divInfo").innerText = text + "\n" + message;
			}
			function getDeviceInfo(){
			    var str = "",i;
			    str += "设备型号：" + plus.device.model + "\n";
			    str += "设备厂商：" + plus.device.vendor + "\n";
			    str += "IMEI：" + plus.device.imei + "\n";
			    str += "UUID: " + plus.device.uuid + "\n";
			    str += "IMSI：";
			    for ( i=0; i<plus.device.imsi.length; i++ ) {
			        str += plus.device.imsi[i];
			    }
			    str += "\n";
			    str += "屏幕分辨率：" + plus.screen.resolutionWidth*plus.screen.scale + " x " + plus.screen.resolutionHeight*plus.screen.scale + "\n";
			    str += "DPI：" + plus.screen.dpiX + " x " + plus.screen.dpiY;
			    outSet( str );
			}
			function getSysInfo() {
			    var str = "";
			    str += "名称：" + plus.os.name + "\n";
			    str += "版本：" + plus.os.version + "\n";
			    str += "语言：" + plus.os.language + "\n";
			    str += "厂商：" + plus.os.vendor + "\n";
			    str += "网络类型：";
			    var types = {};
			    types[plus.networkinfo.CONNECTION_UNKNOW] = "未知";
			    types[plus.networkinfo.CONNECTION_NONE] = "未连接网络";
			    types[plus.networkinfo.CONNECTION_ETHERNET] = "有线网络";
			    types[plus.networkinfo.CONNECTION_WIFI] = "WiFi网络";
			    types[plus.networkinfo.CONNECTION_CELL2G] = "2G蜂窝网络";
			    types[plus.networkinfo.CONNECTION_CELL3G] = "3G蜂窝网络";
			    types[plus.networkinfo.CONNECTION_CELL4G] = "4G蜂窝网络";
			    str += types[plus.networkinfo.getCurrentType()];
			    outSet( str );
			}
			function deviceBeep() {
			    var str = "";
			    switch ( plus.os.name ) {
			    	case "iOS":
					    if ( plus.device.model.indexOf("iPhone") >= 0 ) {
			                plus.device.beep();
					        str += "设备蜂鸣中...";
					    } else {
					        str += "此设备不支持蜂鸣";
					    }
			    	break;
			    	default:
			    		plus.device.beep();
			    		str += "设备蜂鸣中...";
			    	break;
			    }
				outSet( str );
			}
			function deviceVibrate() {
			    var str = "";
			    switch ( plus.os.name ) {
			    	case "iOS":
			            if ( plus.device.model.indexOf("iPhone") >= 0 ) {
			                plus.device.vibrate();
			                str += "设备振动中...";
			            } else {
			                str += "此设备不支持振动";
			            }
			    	break;
			    	default:
			    		plus.device.vibrate();
			            str += "设备振动中...";
			    	break;
			    }
				outSet( str );
			}
			function dial(){
				plus.device.dial("10086",false);
			}
		</script>
	</body>

</html>